// Letter Frequency counter
// Date 08/10/2018
// By Ben

#include <iostream>
#include <vector>

using namespace std;
using std::cout;
using std::endl;
using std::cin;

int countLetters(string source, char c){
	int cnt = 0;
	int i = 0;

	while (i < source.length()){
		if (tolower(source[i]) == tolower(c)){
			cnt++;
		}
		i++;
	}
	return cnt;
}

void LetterFrequency(string source){
	vector<char>letters;
	int lCount = 0;
	char c = '\0';
	for (int i = 0; i < source.length(); i++){
		//Convert char to lowercase.
		c = tolower(source[i]);

		if (std::find(letters.begin(), letters.end(), c) != letters.end()) {
			//Item found in vector
		}
		else{
			//Only get alpha
			if (isalpha(c)){
				//Push letter onto the vector
				letters.push_back(c);
			}
		}
	}
	for (int i = 0; i < letters.size(); i++){
		//Find out how many of letter[i] is in source
		lCount = countLetters(source, letters[i]);
		//Output results
		std::cout << (i+1) << ". " << letters[i] << "  " << lCount << endl;
	}
}

int main(int argc, char *argv[]){
	LetterFrequency("The quick brown fOx jumps over the lazy dog");

	system("pause");
	return 0;
}